package org.apache.continuum.internal.model;

import java.util.List;

import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
import org.apache.maven.continuum.xmlrpc.project.ProjectSummary;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;

public class GroupAdapter implements IAdaptable {

	private ProjectGroupSummary groupSummary;
	private String continuumUrl;
	private GroupPropertySource propertySource;
    private List<BuildDefinition> buildDefinitions;
    private List<ProjectSummary> projects;

	public GroupAdapter(ProjectGroupSummary groupSummary, String continuumUrl) {
		this.groupSummary = groupSummary;
		this.continuumUrl = continuumUrl;
	}

    public String getContiuumUrl() {
    	return continuumUrl;
    }

    public ProjectGroupSummary getGroup() {
    	return groupSummary;
    }

    public void setBuildDefinitions(List<BuildDefinition> buildDefinitions) {
    	this.buildDefinitions = buildDefinitions;
    }

    public List<BuildDefinition> getBuildDefinitions() {
    	return buildDefinitions;
    }

    public void setProjects(List<ProjectSummary> projects) {
    	this.projects = projects;
    }

    public List<ProjectSummary> getProjects() {
    	return projects;
    }

	public Object getAdapter(Class adapter) {
        if (adapter == IPropertySource.class) {
            if (null == propertySource)
                propertySource = new GroupPropertySource ();
            return propertySource;
        }
        return null;
	}

    public class GroupPropertySource implements IPropertySource {

        private IPropertyDescriptor [] propertyDescriptors;


        public boolean isPropertySet(Object id) {
            // TODO Auto-generated method stub
            return false;
        }


        public Object getEditableValue() {
            // TODO Auto-generated method stub
            return null;
        }


        public IPropertyDescriptor [] getPropertyDescriptors() {
            // if (null == this.propertyDescriptors) {
            // // set up descriptors
            // PropertyDescriptor nameDesc = new PropertyDescriptor
            // ("continuum.project.name", "Projects");
            // nameDesc.setCategory ("Projects");
            // PropertyDescriptor buildDesc = new PropertyDescriptor
            // ("continuum.project.builddefinition.name", "Builds");
            // buildDesc.setCategory ("Builds");
            //
            // propertyDescriptors = new IPropertyDescriptor[] { nameDesc,
            // buildDesc};
            //
            // }
            return propertyDescriptors;
        }


        public Object getPropertyValue(Object id) {
            // TODO Auto-generated method stub
            return null;
        }


        public void resetPropertyValue(Object id) {
        // TODO Auto-generated method stub

        }


        public void setPropertyValue(Object id, Object value) {
        // TODO Auto-generated method stub

        }

    }

}
